<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计时器</title>
    <script type="text/javascript">
        var T1,T2,runT,t1,t2;
        T1=new Date();
        t1=T1.toLocaleTimeString()+":"+T1.getMilliseconds();
        document.write("循环前的时间为："+t1)
        var total_sum=0;
        for (var i=1; i<=10000; i++){
            total_sum += i;
        }
        T2=new Date();
        t2=T2.toLocaleTimeString()+":"+T2.getMilliseconds();
        runT=T2.getTime()-T1.getTime();
        document.write("<br>循环时间为："+t2)
        document.write("<br>执行10000次循环的时间为："+runT+"ms")
    </script>
</head>
<body>

</body>
</html>